unit Cons_RegExportacao;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Formulario_Padrao_Consulta, Grids, DBGrids, StdCtrls, Buttons, ExtCtrls,
  TFlatButtonUnit;

type
  TFrmCons_RegExportacao = class(TFrmConsulta)
    dbg: TDBGrid;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure BtnFecharClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FrmCons_RegExportacao: TFrmCons_RegExportacao;
  xcons_registro: string;

implementation

uses dm, db, dbtables, clsRegistroExportacao;

var
  registro: TRegistroExportacao;
  tq: TQuery;
  tds: TDataSource;

{$R *.DFM}

procedure TFrmCons_RegExportacao.FormCreate(Sender: TObject);
begin
  inherited;
  registro := TRegistroExportacao.Create;
  tq := TQuery.Create(self);
  tds := TDataSource.Create(self);
  tq.databasename := dmint.db.databasename;
  tq.active := false;
  tds.dataset := tq;
  dbg.datasource := tds;
end;

procedure TFrmCons_RegExportacao.FormDestroy(Sender: TObject);
begin
  inherited;
  registro.free;
  tq.free;
  tds.free;
end;

procedure TFrmCons_RegExportacao.FormActivate(Sender: TObject);
begin
  inherited;
  registro.Consultar(tq);
end;

procedure TFrmCons_RegExportacao.BtnFecharClick(Sender: TObject);
begin
  inherited;
  xcons_registro := tq.fieldbyname('Reg_Numero').asstring;
end;

end.
